import sys
import os
from ccpm.model.modelusr import ModelUsr
from ccpm.pmbase import PluginBase, PmUtil
from ccpm.glan import Lan
from mgamedev.py_lib.decorator import singleton

from ccpm.collogger import Log


def fmt_verstr(verstr):
    nums = verstr[1:].split(".")
    return int(nums[0]) * 100 + int(nums[1]) * 10 + int(nums[2])


@singleton
class WhoamiPlugin(PluginBase):

    PLUGIN_INFO = dict(
        name="whoami",
        help="whoami >?<  publish package needed!"
    )

    def __init__(self):
        super().__init__(self.PLUGIN_INFO)

    def parser_config(self, argparser):
        super().parser_config(argparser)

    def run(self, argpars):
        super().run(argpars)
        if not PmUtil.chk_usr_enable():
            Log().error(
                Lan.p(self.name, "ERR_CHK_USER"))
            return
        else:
            Log().info(ModelUsr().get_name())


__all__ = [
    "WhoamiPlugin"
]
